﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.IO;
using System.Drawing.Imaging;
using System.Data.SqlClient;
using System.Configuration;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Web.SessionState;
using System.ComponentModel;
using System.Data;
using System.Web.UI.HtmlControls;


namespace iResume
{
    public partial class recruiterPostJob : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView1.Visible = true;
            string username = (string)(Session["username"]);
            string password = (string)(Session["password"]);

            if (username == null)
            {
                Response.Redirect("loginpage.aspx");
            }
        }
        
        //protected void btnButton_Click(object sender, EventArgs e)
        //{
            
        //        GridView1.Visible = true;
        //        string username = (string)(Session["username"]);
        //        string password = (string)(Session["password"]);

        //        if (username == null)
        //        {
        //            Response.Redirect("loginpage.aspx");
        //        }


        //        string salaryRange = ddlSalaryRange.SelectedItem.Text;
        //        string category = ddlDP.SelectedItem.Text;
        //        string jobPosition = tbxPosition.Text;
        //        string jobDescription = tbxDescrpition.Text;
        //        string vacancyAvabile = DropDownList1.SelectedItem.Text;


        //        Recruiter r = new Recruiter(username, salaryRange, jobPosition, category, jobDescription, vacancyAvabile, null);
        //        DBManager.createJobRecruiter(r);
        //        GridView1.DataBind();
        //        ddlSalaryRange.Text = "";
        //        //  ddlDP.Text = "";
        //        tbxDescrpition.Text = "";
        //        tbxPosition.Text = "";
        //        DropDownList1.Text = "";
            
      


        //}

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                // Convert the row index stored in the CommandArgument
                // property to an Integer.
                int index = Convert.ToInt32(e.CommandArgument);

                // Retrieve the row that contains the button clicked 
                // by the user from the Rows collection.
                GridViewRow row = GridView1.Rows[index];

                // Create a new ListItem object for the contact in the row.     
                ListItem item = new ListItem();
              //  Session["username"] = row.Cells[1].Text;
                // item.Text = Server.HtmlDecode(row.Cells[0].Text) + " " + Server.HtmlDecode(row.Cells[1].Text) + " " + Server.HtmlDecode(row.Cells[2].Text) + " " +
                item.Text = Server.HtmlDecode(row.Cells[6].Text) + " ";
                Session ["jobID"] = row.Cells[6].Text;
               // string email = (string)(Session["username"]);



                Response.Redirect("recruiterViewPostJob.aspx");
            }
            if (e.CommandName == "Edit")
            {
                 // Convert the row index stored in the CommandArgument
                // property to an Integer.
                int index = Convert.ToInt32(e.CommandArgument);

                // Retrieve the row that contains the button clicked 
                // by the user from the Rows collection.
                GridViewRow row = GridView1.Rows[index];

                // Create a new ListItem object for the contact in the row.     
                ListItem item = new ListItem();
                //Session["username"] = row.Cells[0].Text;
               // string email = (string)(Session["username"]);
                item.Text = Server.HtmlDecode(row.Cells[6].Text) + " ";
                Session["jobID"] = row.Cells[6].Text;
               // string jobID = row.Cells[6].Text;
                Response.Redirect("recruiterUpdateJob.aspx");
            }
            }

        protected void ddlDP_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("recruiterView.aspx");
        }

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("recruiterPostJob.aspx");
        }

        protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
        {
            GridView1.Visible = true;
            string username = (string)(Session["username"]);
            string password = (string)(Session["password"]);

            if (username == null)
            {
                Response.Redirect("loginpage.aspx");
            }


            string salaryRange = ddlSalaryRange.SelectedItem.Text;
            string category = ddlDP.SelectedItem.Text;
            string jobPosition = tbxPosition.Text;
            string jobDescription = tbxDescrpition.Text;
            string vacancyAvabile = DropDownList1.SelectedItem.Text;


            Recruiter r = new Recruiter(username, salaryRange, jobPosition, category, jobDescription, vacancyAvabile, null);
            DBManager.createJobRecruiter(r);
            GridView1.DataBind();
            ddlSalaryRange.Text = "";
            //  ddlDP.Text = "";
            tbxDescrpition.Text = "";
            tbxPosition.Text = "";
            DropDownList1.Text = "";
            
        }

        }

        

    }
